/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Reporte.java
 *
 * Created on 17/03/2012, 10:38:25 PM
 */

package frontera;

import entidad.Medicion;
import control.TratamientoDatos;
import javax.swing.JOptionPane;


/**
 *
 * @author user
 */
public class Reporte extends javax.swing.JFrame {

    /** Creates new form Reporte */
    public Reporte() {
        initComponents();

        tendenciaBG.add(mediaRB);
        tendenciaBG.add(medianaRB);
        tendenciaBG.add(modaRB);

        dispersionBG.add(desviacionRB);
        dispersionBG.add(varianzaRB);
        dispersionBG.add(rangoRB);

        mediaRB.setSelected(true);
        desviacionRB.setSelected(true);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tendenciaBG = new javax.swing.ButtonGroup();
        dispersionBG = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        mediaRB = new javax.swing.JRadioButton();
        medianaRB = new javax.swing.JRadioButton();
        modaRB = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        desviacionRB = new javax.swing.JRadioButton();
        varianzaRB = new javax.swing.JRadioButton();
        rangoRB = new javax.swing.JRadioButton();
        aceptarB = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Reporte");

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 18)); // NOI18N
        jLabel1.setText("Reporte");
        jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel2.setText("Medidas de tendencia central:");

        mediaRB.setText("Media");

        medianaRB.setText("Mediana");

        modaRB.setText("Moda");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(modaRB)
                    .addComponent(medianaRB)
                    .addComponent(jLabel2)
                    .addComponent(mediaRB))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(mediaRB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(medianaRB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(modaRB)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel4.setText("Medidas de dispersión:");

        desviacionRB.setText("Desviación estándar");

        varianzaRB.setText("Varianza");

        rangoRB.setText("Rango intercuatílico");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rangoRB)
                    .addComponent(varianzaRB)
                    .addComponent(jLabel4)
                    .addComponent(desviacionRB))
                .addContainerGap(53, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addComponent(desviacionRB)
                .addGap(3, 3, 3)
                .addComponent(varianzaRB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rangoRB)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        aceptarB.setText("Aceptar");
        aceptarB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        aceptarB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aceptarBActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(168, 168, 168)
                        .addComponent(aceptarB))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(aceptarB)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void aceptarBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aceptarBActionPerformed

        TratamientoDatos datos = new TratamientoDatos();

        Medicion med1, med2;

        String tendencia;
        String dispersion;

        if (mediaRB.isSelected()) {
            med1 = datos.media();
            tendencia = "media";
        } else if (medianaRB.isSelected()) {
            med1 = datos.mediana();
            tendencia = "mediana";
        } else {
            med1 = datos.moda();
            tendencia = "moda";
        }

        if (desviacionRB.isSelected()) {
            med2 = datos.desviacionEstandar();
            dispersion = "desviacion";
        } else if (varianzaRB.isSelected()) {
            med2 = datos.varianza();
            dispersion = "varianza";
        } else {
            med2 = datos.rangoIntercuartilico();
            dispersion = "rango";
        }

        JOptionPane.showMessageDialog(null, "Medida de tendencia central: " + tendencia
                + "\n\nTemperatura: " + med1.getTemperatura()
                + "\nPresión atmosférica: " + med1.getPresion()
                + "\nPluviosidad: " + med1.getPluviosidad()
                + "\n\nMedida de dispersión: " + dispersion
                + "\n\nTemperatura: " + med2.getTemperatura()
                + "\nPresión atmosférica: " + med2.getPresion()
                + "\nPluviosidad: " + med2.getPluviosidad());

    }//GEN-LAST:event_aceptarBActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton aceptarB;
    private javax.swing.JRadioButton desviacionRB;
    private javax.swing.ButtonGroup dispersionBG;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JRadioButton mediaRB;
    private javax.swing.JRadioButton medianaRB;
    private javax.swing.JRadioButton modaRB;
    private javax.swing.JRadioButton rangoRB;
    private javax.swing.ButtonGroup tendenciaBG;
    private javax.swing.JRadioButton varianzaRB;
    // End of variables declaration//GEN-END:variables

}
